package cn.darkhorse.workorder.domain;

import java.util.ArrayList;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import io.swagger.annotations.*;
import java.util.Date;
import com.ruoyi.common.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;


/**
 * 步骤记录对象 qms_workorder_log
 *
 * @author ytq
 * @date 2024-07-22
 */
@TableName("qms_workorder_log")
@Data
@ApiModel(value = "QmsWorkorderLog", description = "步骤记录对象")
public class QmsWorkorderLog
{
    private static final long serialVersionUID = 1L;

    private Long id;

    /** 流转单编号 */
    @ApiModelProperty(" 流转单编号")
    @Excel(name = "流转单编号")
    private String orderNumber;

    @ApiModelProperty(" 流转工单id")
    private Long workorderId;

    private Date delivery;


    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date sense;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date balance;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date hvi;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date audit;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date upload;

    public Date getDateByStatus(int status) {
        switch (status) {
            case 0:
                return delivery;
            case 1:
                return sense;
            case 2:
                return balance;
            case 3:
                return hvi;
            case 4:
                return audit;
            case 5:
                return upload;
            default:
                return null;
        }
    }

    /**
     * 前置步骤是否有空
     * @param status
     * @return
     */
    public boolean hasNullBeforeStatus(int status) {
        ArrayList<Date> list = new ArrayList<>();
        list.add(delivery);
        list.add(sense);
        list.add(balance);
        list.add(hvi);
        list.add(audit);
        for (int i = 0; i < status; i++) {
            if (list.get(i) == null) {
                return true;
            }
        }
        return false;
    }



    public static String getColumnByStatus(int status) {
        switch (status) {
            case 0:
                return "delivery";
            case 1:
                return "sense";
            case 2:
                return "balance";
            case 3:
                return "hvi";
            case 4:
                return "audit";
            case 5:
                return "upload";
            default:
                return null;
        }
    }
}
